package game;

import engine.Engine;
import engine.game.ESaveLoad;
import engine.game.Game;
import engine.graphics.TextureManager;
import engine.gui.*; 
import engine.gui.events.*;
import game.level.TestLevel;
import game.level.LevelSaveLoad;
import game.gui.*; 

public class JNRGame extends Game {

	private static final long serialVersionUID = 1L;
	
	public JNRGame(Engine e){
		super(e, "Jump'n'Run"); 
		init(); 
	}

	protected void initLevel() {
		this.sl = ESaveLoad.SAVE ;
		this.canSave = false ; 
		if(this.isRunning()){
			switch(this.sl){
			case SAVE:	
				level = new TestLevel(this);
				if(this.canSave)
					new LevelSaveLoad().save(level); 
				break ; 
			case LOAD: level = new LevelSaveLoad().load(this); break ; 
			}
			level.initGUI(); 
		}
		super.initLevel();
	}
	
	@SuppressWarnings("serial")
	@Override
	public void init() {
		
		TextureManager.init(); 
		
		this.mainMenu = new MainMenuScreen(null, this);
		this.pauseMenu = new GamePauseMenuScreen(null, this);
		
		this.mainMenu().addNewButton("Neues Spiel", new EventMethod(){
			public void run(){
				initLevel();
			}
		});
		this.mainMenu().addNewButton("Verlassen", new EventMethod(){
			public void run(){
				engine.exit();
			}
		});
	}


	

}
